package com.woniuxy.hrp.service.Serviceimpl;

import com.woniuxy.hrp.entity.Medicine;
import com.woniuxy.hrp.mapper.MedicineMapper;
import com.woniuxy.hrp.service.MedicineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class MedicineServiceImpl implements MedicineService {
    @Autowired
    private MedicineMapper medicineMapper;

    //查询所有药物
    @Override
    public List<Medicine> findAll() {
        List<Medicine> medicines = medicineMapper.findAll();
        return medicines;
    }

    //根据id查询药物信息
    @Override
    public Medicine findById(int id) {
        Medicine medicine = medicineMapper.findById(id);
        return medicine;
    }

    //增加药物
    @Override
    public void add(Medicine medicine) {
        medicineMapper.insert(medicine);
    }

    //删除药物
    @Override
    public void del(int id) {
        medicineMapper.del(id);
    }

    //修改药物信息
    @Override
    public void update(Medicine medicine) {
        medicineMapper.update(medicine);
    }
}
